package com.haojie.common;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;

@Builder
@Data
public class RPCResponse implements Serializable {
    //封装具体数据类型，并记录传输是否成功的状态码

    private int code; //状态码
    private String msg; //状态信息

    private Object data; //传输的具体数据

    public static RPCResponse success(Object data) {
        return RPCResponse.builder().code(200).data(data).build();
    }

    public static RPCResponse fail() {
        return RPCResponse.builder().code(500).msg("服务器发生错误").build();
    }

}
